/*
 *  Copright: 2008 Philipp Leitner, Distributed Systems Group,
 *            TU Wien, leitner@infosys.tuwien.ac.at
 *
 *  This file is part of DAIOS.
 *
 *  DAIOS is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as
 *  published by the Free Software Foundation.
 * 
 *  DAIOS is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with DAIOS.  If not, see
 *  <http://www.gnu.org/licenses/>.
 * 
 */

package at.ac.tuwien.infosys.dsg.daiosPlugins.nativeInvoker.backend;

import java.util.Hashtable;
import java.util.List;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMElement;

/**
 * A simple helper struct that defines a SOAP response received
 * by the native SOAP stack of Daios. SOAPResponses
 * contain
 * 
 * <pre>
 *   -- The SOAP body in AXIOM representation
 *   -- A list of multirefs (in case of an RPC invocation)
 *   -- a table of HTPP response headers
 *   -- a table of SOAP response headers 
 * </pre>
 * 
 * SOAPResponses are constructed by the Daios native SOAP stack
 * and are immutable.
 * 
 * @author philipp
 *
 */
public class SOAPResponse {
	
	private OMElement body = null;
	private List<OMElement> refs = null; 
	private Hashtable<String, String> httpHeaders = null;
	private Hashtable<QName, String> soapHeaders = null;
	
	/**
	 * Construct a new SOAPResponse. Set all fields of the
	 * struct.
	 * 
	 * @param body
	 * @param refs
	 * @param httpHeaders
	 * @param soapHeaders
	 */
	protected SOAPResponse(OMElement body, List<OMElement> refs,
			Hashtable<String, String> httpHeaders,
			Hashtable<QName, String> soapHeaders) {
		this.body = body;
		this.refs = refs;
		this.httpHeaders = httpHeaders;
		this.soapHeaders = soapHeaders;
	}
	
	/**
	 * Get the SOAP body in AXIOM representation.
	 * 
	 * @return The body.
	 */
	public OMElement getBody() {
		return body;
	}
	
	/**
	 * Get the list of multirefs.
	 * 
	 * @return A list of multirefs in case of
	 * (some) RPC invocations. Null in all other cases.
	 */
	public List<OMElement> getMultirefs() {
		return refs;
	}

	/**
	 * Get all received HTTP headers.
	 * 
	 * @return A table containing all HTTP response headers.
	 */
	public Hashtable<String, String> getHTTPHeaders() {
		return httpHeaders;
	}

	/**
	 * Get all received SOAP headers.
	 * 
	 * @return A table containing all SOAP response headers.
	 */	
	public Hashtable<QName, String> getSOAPHeaders() {
		return soapHeaders;
	}
	
}
